package com.shop.cereshop.app.domain.shop;

import cn.hutool.core.date.DateUtil;
import com.shop.cereshop.commons.domain.calculate.Calculate;
import com.shop.cereshop.commons.domain.shop.CereBusinessTime;
import io.swagger.annotations.ApiModelProperty;

import java.math.BigDecimal;

import com.shop.cereshop.app.page.cart.CartSku;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

@Data
public class CereShopCommentVO {
    /**
     * 店铺id
     */
    @ApiModelProperty(value = "店铺id")
    private Long shopId;

    /**
     * 配送属性,用于区分店铺类型
     */
    @ApiModelProperty(value = "配送属性 1-线下核销 2-快递")
    private Integer driverDistribution;


    /**
     * 商品数据
     */
    @ApiModelProperty(value = "商品数据")
    private List<CartSku> skus;

    /**
     * 设置是否全天
     */
    @ApiModelProperty(value = "设置是否是全天，1-表示是，0表示否")
    private Integer AllDayToUse;


    /**
     * 店铺名称
     */
    @ApiModelProperty(value = "店铺名称")
    private String shopName;


    /**
     * 店铺地址 shop_adress_detail
     */
    @ApiModelProperty(value = "店铺详细地址")
    private String shopAdressDetail;

    /**
     * 店铺省
     */
    @ApiModelProperty(value = "店铺省")
    private String shopProvince;

    /**
     * 市 shop_adress_city
     */
    @ApiModelProperty(value = "店铺市")
    private String shopAdressCity;


    /**
     * 区
     */
    @ApiModelProperty(value = "店铺区")
    private String shopDistrict;


    /**
     * 店铺logo
     */
    @ApiModelProperty(value = "店铺logo")
    private String shopLogo;


    /**
     * 店铺点位地址
     */
    @ApiModelProperty(value = "店铺点位地址")
    private String location;

    /**
     * 店铺类型
     */
    @ApiModelProperty(value = "店铺类型(1-到店服务,2-线上商城/同城配送)")
    private Integer type;

    /**
     * 区域adcode
     */
    @NotNull
    @ApiModelProperty(value = "区域adcode")
    private String adcode;

    /**
     * 主体类型
     */
    @ApiModelProperty(value = "主体类型(1-普通企业店 2-个体工商户 3-品牌旗舰店 4-其他组织)")
    private Integer authenType;


    /**
     * 店铺资质类型字符串形式
     */
    @ApiModelProperty(value = "店铺资质类型字符串形式")
    private String authenTypeStr;

    public void setAuthenTypeStr(Integer authenType) {
        if (authenType == 1) {
            this.authenTypeStr = "普通企业店";
        } else if (authenType == 2) {
            this.authenTypeStr = "个体工商户";
        } else if (authenType == 3) {
            this.authenTypeStr = "品牌旗舰店";
        } else if (authenType == 4) {
            this.authenTypeStr = "其他组织";
        }

    }

    /**
     * 店铺评分
     */
    @ApiModelProperty(value = "店铺评分")
    private BigDecimal commentStar;


    /**
     * 评论总数
     */
    @ApiModelProperty(value = "评论总数")
    private Integer commentTotal;


    /**
     * 店铺营业周期列表
     */
    @ApiModelProperty(value = "营业周期列表")
    private List<CereBusinessTime> shopWeekList;


    public void setServiceLabels(Calculate calculate) {
        List<String> list = new ArrayList<>();
        if (calculate.getShopAllWeekToUer() != null && 1 == calculate.getShopAllWeekToUer()) {
            list.add("全周可用");
        }
        if (calculate.getShopGoodLikeWater() != null && 1 == calculate.getShopGoodLikeWater()) {
            list.add("好评如潮");
        }
        if (calculate.getHotGoods() != null && 1 == calculate.getHotGoods()) {
            list.add("热销店铺");
        }
        if (calculate.getRefundSafe() != null && 1 == calculate.getRefundSafe()) {
            list.add("退款无忧");
        }
        this.serviceLabels = list;
    }

    /**
     * 服务标签
     */
    @ApiModelProperty(value = "服务标签：今日热榜、全周可用、退款无忧、好评如潮")
    private List<String> serviceLabels;


    /**
     * 商家到店铺之间的距离是多少
     */
    @ApiModelProperty(value = "商家到店铺之间的距离是多少")
    private Double userAndShopDistance;


    /**
     * 店铺类型
     */
    @ApiModelProperty(value = "店铺类型(1-到店服务,2-线上商城,3同城配送)")
    private Integer status;

    /**
     * 店铺商品总销量
     */
    @ApiModelProperty(value = "店铺总销量")
    private Integer totalSalesVolume;

    /**
     * 店铺是否是新店
     */
    @ApiModelProperty(value = "是否新店")
    private Integer xinShop;


    @ApiModelProperty(value = "店铺是新店字符形式")
    private String xinShopStr;


    public void setXinShopStr(Integer xinShop) {
        if (xinShop == 1) {
            this.xinShopStr = "新店";
        } else {
            this.xinShopStr = "";
        }
    }

    /**
     * 店铺创建时间
     */
    @ApiModelProperty(value = "店铺创建时间")
    private String createTime;

    @ApiModelProperty(value = "店铺创建时间")
    private Long currentTime;

    public void setCreateTime(String createTime) {
        this.currentTime = DateUtil.parse(createTime, "yyyy-MM-dd HH:mm:ss").getTime();
    }


}
